Active Record
from Data Source Architecture Pattern
Row Data Gatewayにdomain logicを追加したもの
tableとobjectが一対一になる
modelの定義から生やすことで、ORMの結果がmodelになるらしい
code:rb
class User < ActiveRecord::Base
has_many :orders
end
class Order < ActiveRecord::Base
belongs_to :user
has_many :items
end
user = User.find(1)
specific_orders = user.orders.includes(:items).where(items: { name: "特定の商品" })
別途repositoryとか用意しない
modelが、entityとrepositoryの両方の役割を担ってるイメージか
全然しらんけど、あくまでもOOPする上での手軽さ、という印象がある
使用感としてはPrismaとほぼおなじに見える
schma作って、そこからORMを生やすだけ
こちらは結果がclassではなくobjectになっている
OOPしないならこれで十分
P of EAA: Active Record
https://www.wantedly.com/companies/wantedly/post_articles/305592
https://tech.smarthr.jp/entry/2021/11/11/151444
https://speakerdeck.com/yasaichi/architecture-decision-for-the-next-10-years-at-pixta
/miyamonz/active record pattern